/**
  ******************************************************************************
  * File Name          : ctrl_shl.c
  * Description        : Code for data process applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

#ifndef __ctrl_shl_H
#define __ctrl_shl_H

#include <stdint.h>

#define CTRSHL_STORAGE_KEY           "CTRSHL"

/* 高低温阈值 */
typedef struct
{
	int16_t high;
	int16_t low;
}CtrShl_ThresholdType;

/* 时控参数 */
typedef struct
{
	uint8_t  active;
	uint32_t run;
	uint32_t stop;
}CtrShl_TimerctrlType;

/* 其他参数 */
typedef struct
{
	int16_t retntmp;         /* 回差温度 */
}CtrShl_OtherctrlType;

/* 通道私有参数 */
typedef struct
{
	uint8_t en;
	uint8_t sken;
}CtrShl_ChannelPrType;

typedef struct
{
	CtrShl_ThresholdType thrh;
	CtrShl_TimerctrlType timc;
	CtrShl_OtherctrlType othc;
	CtrShl_ChannelPrType chan;
}CtrShl_ParameterType;

typedef struct
{
	char key[8];
	CtrShl_ParameterType para;
}CtrShl_StorageType;

/* io执行状态*/
typedef struct
{
	volatile uint8_t res;
}ctrshl_channel_state_type;

typedef struct
{
	volatile ctrshl_channel_state_type chst;
}CtrShl_StateType;

extern volatile uint8_t CtrShl_TcTickerEn;
extern volatile uint32_t CtrShl_TcTicker;

extern CtrShl_StateType  CtrShl_State;
extern CtrShl_ParameterType CtrShl_RunPara, CtrShl_SetPara;
extern uint8_t CtrShl_RunLogic(int16_t temper, uint32_t ticker, uint8_t *tcen);
extern void CtrShl_Actuator(uint8_t act);
extern void    CtrShl_SavePara(void);
extern uint8_t CtrShl_LoadPara(void);
extern uint8_t CtrShl_CheckPara(CtrShl_ParameterType *para);

#endif /* __ctrl_shl_H */
